package org.mihalovic.PES.data;

import java.util.ArrayList;
//del import org.mihalovic.PES.GUI.SourceDataSelectionPanel;



/**
 * Domains asked by user in SourceDataSelectionPanel panel are stored and available from here.
 * These are taken from the panel only if the selection was changed by user.
 */
public class QueryDomainsHolder {
//del    private SourceDataSelectionPanel panel;
//del    private String[] selectedDomains;
    private String userQuery;
    ArrayList<IQueryChangedListener> changeListeners;


    public QueryDomainsHolder(/*del SourceDataSelectionPanel panel*/) {
//del        this.panel = panel;
//del        this.selectedDomains = new String[0];
        changeListeners = new ArrayList<IQueryChangedListener>();
        userQuery="";
    }

    
    public void addQueryChangedListener(IQueryChangedListener listener) {
        changeListeners.add(listener);
    }


    public String getUserQuery() { return userQuery; }
    public void setUserQuery(String query) {
        userQuery=query;
        if(!changeListeners.isEmpty()) {
            for(IQueryChangedListener listener : changeListeners)
                listener.QueryChanged(userQuery);
        }
    }
    

    /** @return Array of domains selected by user to build a graph */
/*del    public String[] GetSelectedDomains() {              //TODO: this should become obsolete
        if( !panel.DataAreLatest() )
            selectedDomains = panel.GetSelectedDomainIDs();

        return selectedDomains;
    } */
}
